const router = require('koa-router')()
const fs = require('fs')
const path = require('path');
const tool=require('../tool/tool');
var BaseRequest=require('../mongodb/baserequest.js');
var Model=new BaseRequest('topic');


router.prefix('/api/topic');



router.use(async(ctx,next)=>{
    ctx.response.type='json';
    await next();
})
router.post('/add',async function(ctx,next){
    var req=ctx.request;
    console.log(req.body);
    var result=await Model.save(req.body);
    ctx.body=result;
});
router.post('/list',async function(ctx,next){
    var req=ctx.request;
    //console.log(req.body);
    var result=await Model.queryPage({},{page:req.body.currentPage,limit:req.body.pageSize})
    //console.log(result);
    ctx.body=result;
    //ctx.body={data:{list:[]}}
})
module.exports=router;